@(issues: List[gitbucket.core.service.RepositorySearchService.IssueSearchResult],
  pullRequest: Boolean,
  query: String,
  page: Int,
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@import gitbucket.core.service.RepositorySearchService
@gitbucket.core.html.main("Search Results", Some(repository)){
  @gitbucket.core.search.html.menu(if(pullRequest) "pulls" else "issues", query, repository){
    @if(query.nonEmpty) {
      @if(issues.isEmpty) {
        <h4>We couldn't find any @{if(pullRequest) "pull requests" else "issues"} matching '@query'</h4>
      } else {
        <h4>We've found @issues.size @helpers.plural(issues.size, if(pullRequest) "pull request" else "issue")</h4>
      }
    }
    @issues.drop((page - 1) * RepositorySearchService.IssueLimit).take(RepositorySearchService.IssueLimit).map { issue =>
      <div class="block">
        <div class="pull-right muted">
          @if(issue.isClosed){
            <span class="label label-danger">Closed</span>
          }
          #@issue.issueId
        </div>
        <h4 style="margin-top: 0px;"><a href="@helpers.url(repository)/@if(issue.isPullRequest){pull} else {issues}/@issue.issueId">@issue.title</a></h4>
        @if(issue.highlightText.nonEmpty){
          <pre>@Html(issue.highlightText)</pre>
        }
        <div class="small muted">
          Opened by <a href="@helpers.url(issue.openedUserName)" class="username">@issue.openedUserName</a>
          @gitbucket.core.helper.html.datetimeago(issue.registeredDate)
          @if(issue.commentCount > 0){
            &nbsp;&nbsp;<i class="octicon octicon-comment"></i>
            <span class="strong">@issue.commentCount</span> @helpers.plural(issue.commentCount, "comment")
          }
        </div>
      </div>
    }
    @gitbucket.core.helper.html.paginator(page, issues.size, RepositorySearchService.IssueLimit, 10,
      s"${helpers.url(repository)}/search?q=${helpers.urlEncode(query)}&type=${if(pullRequest) "pulls" else "issues"}")
  }
}
